package com.ruoyi.web.controller.comlbs;


import com.ruoyi.system.domain.request.alarmrule.AlarmRulePersonVehicleParam;
import com.ruoyi.system.domain.request.alarmrule.BindAlarmRuleParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IAlarmRulePersonVehicleService;

/**
 * 告警规则绑定人和车的中间Controller
 * 
 * @author wp
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/comlbs/alarmRulePersonVehicle")
public class AlarmRulePersonVehicleController extends BaseController {
    @Autowired
    private IAlarmRulePersonVehicleService alarmRulePersonVehicleService;

    @ApiOperation("报警规则绑定监管对象列表")
    @PostMapping("/list")
    public AjaxResult list(@Validated @RequestBody AlarmRulePersonVehicleParam param) {
        return success(alarmRulePersonVehicleService.selectList(param));
    }

    @ApiOperation("报警规则绑定监管对象")
    @Log(title = "报警规则绑定监管对象", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult bindObject(@Validated @RequestBody BindAlarmRuleParam param) {
        alarmRulePersonVehicleService.bindObject(param);
        return success();
    }

    @ApiOperation("监管对象绑定的报警规则列表")
    @GetMapping("/binding/list")
    public AjaxResult bindingList(@RequestParam Long objectId){
        return success(alarmRulePersonVehicleService.bindingList(objectId));
    }
}
